home *** CD-ROM | disk | FTP | other *** search
- Path: softsite.co.at!wsog
- Date: 17 Jan 1996 09:11:00 +0200
- From: wsog@softsite.co.at (Walter Sommergruber)
- Newsgroups: comp.lang.c
- Message-ID: <613O-oOMnTB@softsite.co.at>
- References: <4d9k6fINNnja@faatcrl.faa.gov> <4dc6kq$dja@gryphon.phoenix.net>
- <DL9GIA.4y1@eskimo.com>
- Subject: Re: Checking for a file => Does it exist (Help)
- X-Newsreader: XP v3.02
- X-Charset: ISO-8859-1
- Organization: Sommergruber Software & Dienstleistungen
-
- mAg (mag@eskimo.com) wrote on 16.01.96
- about "Re: Checking for a file => Does it exist (Help)":
-
- > In article <4dc6kq$dja@gryphon.phoenix.net> (Mon, 15 Jan 1996 01:00:31 GMT),
- > brucew@phoenix.net says :
- > >afrawert@faatcrl.faa.gov (Alan Frawert) wrote:
- > >>I'm having a problem just checking to see if a file
- > >>exists. Does anyone have a simple piece of code that I can use?
- > >
- > >Well, you could try to open it then close it:
- > Just a little smarter(?) version :-)
- >
- > int file_exist(char *fname)
- > {
- > FILE *fp;
- > if (fp = fopen(fname,"r"))
- > {
- > fclose(fp);
- > return(1);
- > }
- > return (0);
- > }
-
- What is if the file exists but you have not the right to read it ?
- The fopen would fail but the file exists.
- I know the non-portable ways with fstat (DOS, Unix) but is there
- a portable way to tell if the file exists ?
-
- --- Take a look at ...
- Walter Sommergruber The Software Site
- email: wsog@softsite.co.at http://www.softsite.co.at/softsite/
-